module.exports = new function () {
    return {
        init: function(r, listener, failureListener, context) {
            /*
                var data = [
                    { name: 'Hartsfield Jackson Atlanta International', code: 'ATL' },
                    { name: 'Beijing Capital International', code: 'PEK' },
                    { name: 'London Heathrow', code: 'LHR' },
                    { name: 'Tokyo International', code: 'HND' },
                    { name: 'Chicago O\'Hare International', code: 'ORD' },
                    { name: 'Los Angeles International', code: 'LAX' },
                    { name: 'Charles de Gaulle International', code: 'CDG' },
                    { name: 'Dallas Fort Worth International', code: 'DFW' },
                    { name: 'Soekarno-Hatta International', code: 'CGK' },
                    { name: 'Dubai International', code: 'DXB' },
                    { name: 'Frankfurt am Main International', code: 'FRA' },
                    { name: 'Hong Kong International Kai Tak', code: 'HKG' },
                    { name: 'Denver International', code: 'DEN' },
                    { name: 'Suvarnabhumi', code: 'BKK' },
                    { name: 'Singapore Changi International', code: 'SIN' },
                    { name: 'Amsterdam Schiphol', code: 'AMS' },
                    { name: 'John F Kennedy International', code: 'JFK' },
                    { name: 'Guangzhou Baiyun International', code: 'CAN' },
                    { name: 'Madrid Barajas International', code: 'MAD' },
                    { name: 'Atatürk International', code: 'IST' },
                    { name: 'Shanghai Pudong International', code: 'PVG' },
                    { name: 'San Francisco International', code: 'SFO' },
                    { name: 'Charlotte Douglas International', code: 'CLT' },
                    { name: 'McCarran International', code: 'LAS' },
                    { name: 'Phoenix Sky Harbor International', code: 'PHX' },
                    { name: 'George Bush Intercontinental Houston', code: 'IAH' },
                    { name: 'Kuala Lumpur International', code: 'KUL' },
                    { name: 'Miami International', code: 'MIA' },
                    { name: 'Incheon International', code: 'ICN' },
                    { name: 'Munich International', code: 'MUC' },
                    { name: 'Sydney Kingsford Smith International', code: 'SYD' },
                    { name: 'Leonardo Da Vinci (Fiumicino) International', code: 'FCO' },
                    { name: 'Orlando International', code: 'MCO' },
                    { name: 'Barcelona International', code: 'BCN' },
                    { name: 'Lester B. Pearson International', code: 'YYZ' },
                    { name: 'London Gatwick', code: 'LGW' },
                    { name: 'Indira Gandhi International', code: 'DEL' },
                    { name: 'Newark Liberty International', code: 'EWR' },
                    { name: 'Shanghai Hongqiao International', code: 'SHA' },
                    { name: 'Seattle Tacoma International', code: 'SEA' },
                    { name: 'Minneapolis-St Paul International/Wold-Chamberlain', code: 'MSP' },
                    { name: 'Narita International', code: 'NRT' },
                    { name: 'Guarulhos - Governador André Franco Montoro International', code: 'GRU' },
                    { name: 'Detroit Metropolitan Wayne County', code: 'DTW' },
                    { name: 'Ninoy Aquino International', code: 'MNL' },
                    { name: 'Chengdu Shuangliu International', code: 'CTU' },
                    { name: 'Philadelphia International', code: 'PHL' },
                    { name: 'Chhatrapati Shivaji International', code: 'BOM' },
                    { name: 'Shenzhen Bao\'an International', code: 'SZX' },
                    { name: 'Melbourne International', code: 'MEL'}
                ];
                var collection = context.db.get('airports');
                data.forEach(function(e) {
                    collection.insert(e);
                });
                */
                listener({success: true});
        },
        list: function(r, listener, failureListener, context) {
            var collection = context.db.get('airports');
            collection.find({}, {}, function(e, docs) {
                if (e) {
                    failureListener(500, e.toString());
                    return;
                }
                listener({ success: true, data: docs });
            });
		}
    };
};